package com.shigen.demo.algorithm;

import java.util.Arrays;

/**
 * 给定一组非负整数，重新排列它们的顺序使之组成一个最大的整数
 *
 * @author shigenfu
 * @date 2022/5/29 2:19 下午
 */
public class MaxInteger {

  public static void main(String[] args) {
    /**
     * 输入：[5, 60, 2, 80, 342]
     *     输出：865432200
     */
    final StringBuilder stringBuilder = new StringBuilder();
    Integer[] inputs = new Integer[]{5, 60, 2, 80, 342};
    for (Integer input : inputs) {
      stringBuilder.append(input);
    }

    String[] nums = stringBuilder.toString().split("");
    System.out.println(Arrays.toString(nums));
    Arrays.sort(nums, (o1, o2) -> - o1.compareTo(o2));
    System.out.println(String.join("", nums));


  }

}
